<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>使用Python脚本对GiteePages进行一键部署 | 水墨社区</title><meta name="keywords" content="部署,Gitee"><meta name="author" content="Langkye"><meta name="copyright" content="Langkye"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="description" content="本次系统环境  os: Deepin（Linux）Python: 3.7lib: PyYAML&#x3D;&#x3D;5.3.1 | selenium&#x3D;&#x3D;3.141.0extend_driver: chromedriver  使用说明参数Python脚本和config.yaml配置文件中包含的参数信息 12345repo_user_name &#x3D; &quot;Gitee用户名&quot;repo_name &#x3D; &amp;quo">
<meta property="og:type" content="article">
<meta property="og:title" content="使用Python脚本对GiteePages进行一键部署">
<meta property="og:url" content="http://langkye.gitee.io/2020/12/31/%E4%BD%BF%E7%94%A8Python%E8%84%9A%E6%9C%AC%E5%AF%B9GiteePages%E8%BF%9B%E8%A1%8C%E4%B8%80%E9%94%AE%E9%83%A8%E7%BD%B2/index.html">
<meta property="og:site_name" content="水墨社区">
<meta property="og:description" content="本次系统环境  os: Deepin（Linux）Python: 3.7lib: PyYAML&#x3D;&#x3D;5.3.1 | selenium&#x3D;&#x3D;3.141.0extend_driver: chromedriver  使用说明参数Python脚本和config.yaml配置文件中包含的参数信息 12345repo_user_name &#x3D; &quot;Gitee用户名&quot;repo_name &#x3D; &amp;quo">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://api.uomg.com/api/rand.avatar">
<meta property="article:published_time" content="2020-12-31T02:23:36.000Z">
<meta property="article:modified_time" content="2020-12-31T08:30:43.871Z">
<meta property="article:author" content="Langkye">
<meta property="article:tag" content="GiteePages">
<meta property="article:tag" content="Python">
<meta property="article:tag" content="自动化">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://api.uomg.com/api/rand.avatar"><link rel="shortcut icon" href="/static/images/favicon.png"><link rel="canonical" href="http://langkye.gitee.io/2020/12/31/%E4%BD%BF%E7%94%A8Python%E8%84%9A%E6%9C%AC%E5%AF%B9GiteePages%E8%BF%9B%E8%A1%8C%E4%B8%80%E9%94%AE%E9%83%A8%E7%BD%B2/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="preconnect" href="//zz.bdstatic.com"/><meta name="baidu-site-verification" content="AHIEgFLu2LfnnTxU"/><link rel="manifest" href="/manifest.json"/><link rel="apple-touch-icon" sizes="180x180" href="/static/images/pwa/safari/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/static/images/pwa/classic/favicon/32/favicon.ico"/><link rel="icon" type="image/png" sizes="16x16" href="/static/images/pwa/classic/favicon/16/favicon.ico"/><link rel="mask-icon" href="/static/images/pwa/safari/safari-pinned-tab.svg" color="#5bbad5"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?c6f123cc670df372deeda2ebd4aa956f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>var GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":10,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'mediumZoom',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"bottom-left"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: true
};

var saveToLocal = {
  set: function setWithExpiry(key, value, ttl) {
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}

// https://stackoverflow.com/questions/16839698/jquery-getscript-alternative-in-native-javascript
const getScript = url => new Promise((resolve, reject) => {
  const script = document.createElement('script')
  script.src = url
  script.async = true
  script.onerror = reject
  script.onload = script.onreadystatechange = function() {
    const loadState = this.readyState
    if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
    script.onload = script.onreadystatechange = null
    resolve()
  }
  document.head.appendChild(script)
})</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2020-12-31 16:30:43'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
   if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }
  const autoChangeMode = 'false'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
   if (asideStatus === 'hide') {
     document.documentElement.classList.add('hide-aside')
   } else {
     document.documentElement.classList.remove('hide-aside')
   }
}const fontSizeVal = saveToLocal.get('global-font-size')
if (fontSizeVal !== undefined) {
  document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
}})()</script><meta name="baidu_union_verify" content="efe8434707795cbe576ee42ad6c9040c"><meta name="baidu-site-verification" content="code-gD8qIjnHxV" /><style type="text/css">.app-refresh{position:fixed;top:-2.2rem;left:0;right:0;z-index:99999;padding:0 1rem;font-size:15px;height:2.2rem;transition:all .3s ease}.app-refresh-wrap{display:flex;color:#fff;height:100%;align-items:center;justify-content:center}.app-refresh-wrap a{color:#fff;text-decoration:underline;cursor:pointer}</style><link rel="stylesheet" href="//at.alicdn.com/t/font_2300836_m8h16i9he7h.css"><meta name="generator" content="Hexo 5.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="/static/images/profile/actar.jpeg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">2</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/shuoshuo"><i class="fa-fw fa fa-heartbeat"></i><span> 碎碎念</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page" href="/books/"><i class="fa-fw fas fa-book"></i><span> 书籍</span></a></li><li><a class="site-page" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li><li><a class="site-page" href="/games/"><i class="fa-fw fas fa-dice"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(https://api.uomg.com/api/rand.avatar)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">水墨社区</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/shuoshuo"><i class="fa-fw fa fa-heartbeat"></i><span> 碎碎念</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page" href="/books/"><i class="fa-fw fas fa-book"></i><span> 书籍</span></a></li><li><a class="site-page" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li><li><a class="site-page" href="/games/"><i class="fa-fw fas fa-dice"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">使用Python脚本对GiteePages进行一键部署</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2020-12-31T02:23:36.000Z" title="发表于 2020-12-31 10:23:36">2020-12-31</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2020-12-31T08:30:43.871Z" title="更新于 2020-12-31 16:30:43">2020-12-31</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E5%8D%9A%E5%AE%A2/">博客</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E5%8D%9A%E5%AE%A2/Python/">Python</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.3k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>5分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p><strong>本次系统环境</strong></p>
<blockquote>
<p>os: Deepin（Linux）<br>Python: 3.7<br>lib: PyYAML==5.3.1 | selenium==3.141.0<br>extend_driver: chromedriver</p>
</blockquote>
<h1 id="使用说明"><a href="#使用说明" class="headerlink" title="使用说明"></a>使用说明</h1><h2 id="参数"><a href="#参数" class="headerlink" title="参数"></a>参数</h2><p>Python脚本和config.yaml配置文件中包含的参数信息</p>
<figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">repo<span class="emphasis">_user_</span>name = &quot;Gitee用户名&quot;</span><br><span class="line">repo<span class="emphasis">_name = &quot;仓库名&quot;</span></span><br><span class="line"><span class="emphasis">login_</span>user = &quot;登录用户&quot;</span><br><span class="line">login<span class="emphasis">_pwd = &quot;登录密码&quot;</span></span><br><span class="line"><span class="emphasis">os = &quot;输入数值1~~3(你的操作系统:1 Linux | 2 Mac | 3 Windows)&quot;</span></span><br></pre></td></tr></table></figure>

<h2 id="驱动"><a href="#驱动" class="headerlink" title="驱动"></a>驱动</h2><blockquote>
<p>本文使用的是 <code>Linux 87.0.4280.88（正式版本） （64 位）</code></p>
</blockquote>
<p>你需要根据你的操作系统和谷歌浏览器选择对应的驱动。如果你的浏览器版本与我的一致,那么恭喜你^_^,直接拿去用吧~我已经把Linux、Mac和Windows的驱动准备好了。</p>
<p>如果你的谷歌浏览器版本与我的不一致也不要紧,下面我会告诉你如何下载与配置。</p>
<ol>
<li><p>查看你的chrome版本</p>
<p>在chrome浏览器地址栏输入: chrome://version/ 查看自己的版本信息。</p>
<p>然后你将看到:<br><img src="https://gitee.com/langkye/imagesBed/raw/master/gitee_blog/img/20201231162418.png"><br>或者在设置里查看:<br><img src="https://gitee.com/langkye/imagesBed/raw/master/gitee_blog/img/20201230180937.png" alt="chrome版本"></p>
</li>
<li><p>下载驱动</p>
<p>选择自己的驱动 Windows|Linux|Mac。 驱动下载: <a target="_blank" rel="noopener" href="http://npm.taobao.org/mirrors/chromedriver/">地址</a></p>
</li>
</ol>
<ol start="3">
<li><p>重要提示: 需要把驱动放到下面两个路径下</p>
<p>1.谷歌的安装路径</p>
<p>2.python的安装路径</p>
</li>
</ol>
<h1 id="Python环境"><a href="#Python环境" class="headerlink" title="Python环境"></a>Python环境</h1><blockquote>
<p>为了避免干扰,我使用虚拟环境来进行管理。</p>
<p>当然你使用安装系统安装的环境也没关系。</p>
</blockquote>
<h2 id="使用安装环境"><a href="#使用安装环境" class="headerlink" title="使用安装环境"></a>使用安装环境</h2><ol>
<li><p>安装依赖库</p>
<p>在<code>requirements.txt</code>所在目录执行:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install -r requirements.txt</span><br></pre></td></tr></table></figure>
<h2 id="创建寻环境"><a href="#创建寻环境" class="headerlink" title="创建寻环境"></a>创建寻环境</h2></li>
<li><p>创建目录, 并进入该目录</p>
 <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p ~/Virtualenv/Python37 &amp;&amp; <span class="built_in">cd</span> ~/Virtualenv/Python37</span><br></pre></td></tr></table></figure></li>
<li><p>创建虚拟环境</p>
 <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python3 -m venv python</span><br></pre></td></tr></table></figure>
<p>如果报错:</p>
 <figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">The virtual environment was not created successfully because ensurepip is not</span><br><span class="line">available</span><br></pre></td></tr></table></figure>
<p>执行:</p>
 <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">apt-get install python3-venv</span><br></pre></td></tr></table></figure></li>
<li><p>切换到虚拟环境</p>
<blockquote>
<p>如果使用IDE,直接将脚本切换为虚拟环境的可执行程序。<br>如果使用命令行,可以直接切换到寻虚拟环境所在的目录,直接执行即可;或者执行虚拟环境中的<code>active</code>。(Windows 脚本在Script下| Linux、Mac在bin下)<br>e.g. 对于Linux: source ./bin/activate</p>
</blockquote>
</li>
<li><p>安装该本脚本需要的依赖包</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install -r requirements.txt</span><br></pre></td></tr></table></figure>
<h2 id="运行脚本"><a href="#运行脚本" class="headerlink" title="运行脚本"></a>运行脚本</h2></li>
<li><p>准备你的仓库信息<br>我提供了通过键盘输入和配置文件两种方式来获取你的仓库和密码等信息。</p>
<p>默认是读取配置文件的方式进行获取。如果你要切换,你可以在<code>bin.py</code>的文件末尾进行配置,我做了说明。</p>
</li>
<li><p>执行脚本<br>如果你已经了解并准备好了,那么直接执行它吧~</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python bin.py</span><br></pre></td></tr></table></figure>
<h1 id="附录"><a href="#附录" class="headerlink" title="附录"></a>附录</h1><p>脚本|驱动|配置文件等信息,到我的Gitee上下载-&gt;<a href="https://gitee.com/langkye/repo/tree/master/redeploy_gitee_page" target="_blank">地址</a></p>
</li>
<li><p>配置文件:config.yaml</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">repo_user_name:</span> <span class="string">仓库用户</span></span><br><span class="line"><span class="attr">repo_name:</span> <span class="string">仓库名</span></span><br><span class="line"><span class="attr">login_user:</span> <span class="string">登录名</span></span><br><span class="line"><span class="attr">login_pwd:</span> <span class="string">登录密码</span></span><br><span class="line"><span class="attr">os:</span> <span class="number">1</span></span><br></pre></td></tr></table></figure></li>
<li><p>Python脚本:bin.py</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">##! ~/Virtualenv/Python37/python/bin/python</span></span><br><span class="line"><span class="comment"># -*- coding:utf-8 -*-</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> selenium <span class="keyword">import</span> webdriver</span><br><span class="line"><span class="keyword">from</span> selenium.webdriver.chrome.options <span class="keyword">import</span> Options</span><br><span class="line"><span class="keyword">from</span> selenium.webdriver.common.by <span class="keyword">import</span> By</span><br><span class="line"><span class="keyword">from</span> selenium.webdriver.support <span class="keyword">import</span> expected_conditions <span class="keyword">as</span> EC</span><br><span class="line"><span class="keyword">from</span> selenium.webdriver.support.ui <span class="keyword">import</span> WebDriverWait <span class="keyword">as</span> Wait</span><br><span class="line"><span class="keyword">import</span> yaml</span><br><span class="line"><span class="keyword">import</span> os</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">redeploy</span>(<span class="params">repo_user_name, repo_name, login_user, login_pwd, oSystem</span>):</span></span><br><span class="line">    print(<span class="string">&quot;\nstart refresh gitee pages...&quot;</span>)</span><br><span class="line"></span><br><span class="line">    os_type = &#123;</span><br><span class="line">        <span class="string">&#x27;1&#x27;</span>: <span class="string">&#x27;chromedriver_linux&#x27;</span>,</span><br><span class="line">        <span class="string">&#x27;2&#x27;</span>: <span class="string">&#x27;chromedriver_mac&#x27;</span>,</span><br><span class="line">        <span class="string">&#x27;3&#x27;</span>: <span class="string">&#x27;chromedriver_win.exe&#x27;</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    url = <span class="string">&quot;https://gitee.com/&quot;</span> + repo_user_name + <span class="string">&quot;/&quot;</span> + repo_name + <span class="string">&quot;/pages&quot;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment"># path = os.path.dirname(os.path.realpath(__file__))</span></span><br><span class="line">    <span class="comment"># driver_path = &quot;script/&#123;&#125;&quot;.format(os_type[oSystem])</span></span><br><span class="line">    driver = os.path.abspath(<span class="string">&quot;script/chromedriver_linux&quot;</span>)</span><br><span class="line">    chrome_options = Options()</span><br><span class="line">    chrome_options.add_argument(<span class="string">&quot;--window-size=1920,1080&quot;</span>)</span><br><span class="line">    chrome_options.add_argument(<span class="string">&quot;--start-maximized&quot;</span>)</span><br><span class="line">    chrome_options.add_argument(<span class="string">&quot;--headless&quot;</span>)</span><br><span class="line">    browser = webdriver.Chrome(executable_path=driver, options=chrome_options)</span><br><span class="line"></span><br><span class="line">    browser.get(url)</span><br><span class="line"></span><br><span class="line">    Wait(browser, <span class="number">10</span>).until(EC.presence_of_element_located((By.CLASS_NAME, <span class="string">&quot;item.git-nav-user__login-item&quot;</span>)))</span><br><span class="line">    print(<span class="string">&quot;load finish. url=&quot;</span> + url)</span><br><span class="line">    login_btn = browser.find_element_by_class_name(<span class="string">&quot;item.git-nav-user__login-item&quot;</span>)</span><br><span class="line">    login_btn.click()</span><br><span class="line"></span><br><span class="line">    Wait(browser, <span class="number">10</span>).until(EC.presence_of_element_located((By.ID, <span class="string">&quot;user_login&quot;</span>)))</span><br><span class="line">    Wait(browser, <span class="number">10</span>).until(EC.presence_of_element_located((By.ID, <span class="string">&quot;user_password&quot;</span>)))</span><br><span class="line">    print(<span class="string">&quot;login page load finish.&quot;</span>)</span><br><span class="line">    user_input = browser.find_element_by_id(<span class="string">&quot;user_login&quot;</span>)</span><br><span class="line">    pwd_input = browser.find_element_by_id(<span class="string">&quot;user_password&quot;</span>)</span><br><span class="line">    login_btn = browser.find_element_by_name(<span class="string">&quot;commit&quot;</span>)</span><br><span class="line">    user_input.send_keys(login_user)</span><br><span class="line">    pwd_input.send_keys(login_pwd)</span><br><span class="line">    login_btn.click()</span><br><span class="line"></span><br><span class="line">    Wait(browser, <span class="number">10</span>).until(</span><br><span class="line">        EC.presence_of_element_located((By.CLASS_NAME, <span class="string">&quot;button.orange.redeploy-button.ui.update_deploy&quot;</span>)))</span><br><span class="line">    print(<span class="string">&quot;login finish.&quot;</span>)</span><br><span class="line">    deploy_btn = browser.find_element_by_class_name(<span class="string">&#x27;button.orange.redeploy-button.ui.update_deploy&#x27;</span>)</span><br><span class="line"></span><br><span class="line">    browser.execute_script(<span class="string">&quot;window.scrollTo(100, document.body.scrollHeight);&quot;</span>)</span><br><span class="line">    deploy_btn.click()</span><br><span class="line">    dialog = browser.switch_to.alert</span><br><span class="line">    dialog.accept()</span><br><span class="line">    print(<span class="string">&quot;refresh gitee pages finish.&quot;</span>)</span><br><span class="line">    browser.close()</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">input_required</span>():</span></span><br><span class="line">    repo_user_name = <span class="built_in">input</span>(<span class="string">&quot;仓库用户名称:\n&gt;&gt;&gt;&quot;</span>)</span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">len</span>(repo_user_name) == <span class="number">0</span>:</span><br><span class="line">        print(<span class="string">&quot;输入不能为空!请重新输入&quot;</span>)</span><br><span class="line">        input_required()</span><br><span class="line"></span><br><span class="line">    repo_name = <span class="built_in">input</span>(<span class="string">&quot;仓库名称:\n&gt;&gt;&gt;&quot;</span>)</span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">len</span>(repo_name) == <span class="number">0</span>:</span><br><span class="line">        print(<span class="string">&quot;输入不能为空!请重新输入&quot;</span>)</span><br><span class="line">        input_required()</span><br><span class="line"></span><br><span class="line">    login_user = <span class="built_in">input</span>(<span class="string">&quot;登录用户名称:\n&gt;&gt;&gt;&quot;</span>)</span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">len</span>(login_user) == <span class="number">0</span>:</span><br><span class="line">        print(<span class="string">&quot;输入不能为空!请重新输入&quot;</span>)</span><br><span class="line">        input_required()</span><br><span class="line"></span><br><span class="line">    login_pwd = <span class="built_in">input</span>(<span class="string">&quot;登录密码:\n&gt;&gt;&gt;&quot;</span>)</span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">len</span>(login_pwd) == <span class="number">0</span>:</span><br><span class="line">        print(<span class="string">&quot;输入不能为空!请重新输入&quot;</span>)</span><br><span class="line">        input_required()</span><br><span class="line"></span><br><span class="line">    oSystem = <span class="built_in">input</span>(<span class="string">&quot;当前操作系统(默认Linux)\n\t**&lt; 1:Linux | 2:Mac | 3:Windows &gt;**\n&gt;&gt;&gt;&quot;</span>)</span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">len</span>(os) == <span class="number">0</span>:</span><br><span class="line">        redeploy(repo_user_name, repo_name, login_user, login_pwd, <span class="string">&quot;1&quot;</span>)</span><br><span class="line"></span><br><span class="line">    redeploy(repo_user_name, repo_name, login_user, login_pwd, oSystem)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">reade_conf</span>():</span></span><br><span class="line">    path = os.path.dirname(os.path.realpath(__file__))</span><br><span class="line">    config = os.path.join(path, <span class="string">&quot;config.yaml&quot;</span>)</span><br><span class="line"></span><br><span class="line">    f = <span class="built_in">open</span>(config)  <span class="comment"># 打开yaml文件</span></span><br><span class="line"></span><br><span class="line">    <span class="comment"># d = yaml.load(f) ##yaml5.1之前的版本：使用load方法加载</span></span><br><span class="line">    d = yaml.load(f, Loader=yaml.FullLoader)  <span class="comment">##yaml5.1之后的版本:使用load方法加载</span></span><br><span class="line"></span><br><span class="line">    repo_user_name = d[<span class="string">&#x27;repo_user_name&#x27;</span>]</span><br><span class="line">    repo_name = d[<span class="string">&#x27;repo_name&#x27;</span>]</span><br><span class="line">    login_user = d[<span class="string">&#x27;login_user&#x27;</span>]</span><br><span class="line">    login_pwd = d[<span class="string">&#x27;login_pwd&#x27;</span>]</span><br><span class="line">    oSystem = <span class="built_in">str</span>(d[<span class="string">&#x27;os&#x27;</span>])</span><br><span class="line"></span><br><span class="line">    redeploy(repo_user_name, repo_name, login_user, login_pwd, oSystem)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&#x27;__main__&#x27;</span>:</span><br><span class="line">    <span class="comment"># 方式一:通过键盘输入必要信息</span></span><br><span class="line">    <span class="comment"># input_required()</span></span><br><span class="line"></span><br><span class="line">    <span class="comment"># 方式二:通过config.yaml配置文件</span></span><br><span class="line">    reade_conf()</span><br></pre></td></tr></table></figure>
<h1 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h1></li>
<li><p><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/19cc4eb0f199">https://www.jianshu.com/p/19cc4eb0f199</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/wulixia/p/11200023.html">https://www.cnblogs.com/wulixia/p/11200023.html</a></p>
</li>
</ol>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Langkye</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://langkye.gitee.io/2020/12/31/%E4%BD%BF%E7%94%A8Python%E8%84%9A%E6%9C%AC%E5%AF%B9GiteePages%E8%BF%9B%E8%A1%8C%E4%B8%80%E9%94%AE%E9%83%A8%E7%BD%B2/">http://langkye.gitee.io/2020/12/31/%E4%BD%BF%E7%94%A8Python%E8%84%9A%E6%9C%AC%E5%AF%B9GiteePages%E8%BF%9B%E8%A1%8C%E4%B8%80%E9%94%AE%E9%83%A8%E7%BD%B2/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://langkye.gitee.io" target="_blank">水墨社区</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/GiteePages/">GiteePages</a><a class="post-meta__tags" href="/tags/Python/">Python</a><a class="post-meta__tags" href="/tags/%E8%87%AA%E5%8A%A8%E5%8C%96/">自动化</a></div><div class="post_share"><div class="addthis_inline_share_toolbox"></div><script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5feb48176dadb0bd" async="async"></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏<div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/static/images/payment/WeChatPay.bmp" target="_blank"><img class="post-qr-code-img" src="/static/images/payment/WeChatPay.bmp" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/static/images/payment/Alipay.bmp" target="_blank"><img class="post-qr-code-img" src="/static/images/payment/Alipay.bmp" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div></div><nav class="pagination-post" id="pagination"><div class="next-post pull-full"><a href="/2020/12/30/%E6%90%AD%E5%BB%BA%E5%9F%BA%E4%BA%8EGiteePages%E7%9A%84%E5%9B%BE%E5%BA%8A/"><img class="next-cover" src="https://api.uomg.com/api/rand.avatar" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">搭建基于GiteePages的图床</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="gitalk-container"></div></div></div></div></div><div class="aside_content" id="aside_content"><div class="card-widget card-info"><div class="card-content"><div class="card-info-avatar is-center"><img class="avatar-img" src="/static/images/profile/actar.jpeg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">Langkye</div><div class="author-info__description">社区,资源,分享</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">2</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/langkye"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/langkye" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="http://wpa.qq.com/msgrd?v=3&amp;uin=878057221&amp;site=qq&amp;menu=yes" target="_blank" title=""><i class="fab fa-qq"></i></a><a class="social-icon" href="mailto:langkye@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://langkye.github.io/" target="_blank" title=""><i class="fab fa-dribbble"></i></a><a class="social-icon" href="/atom.xml" target="_blank" title=""><i class="fas fa-rss"></i></a></div></div></div><div class="card-widget card-announcement"><div class="card-content"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">有问题请留言~</div></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="card-content"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E"><span class="toc-number">1.</span> <span class="toc-text">使用说明</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E6%95%B0"><span class="toc-number">1.1.</span> <span class="toc-text">参数</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A9%B1%E5%8A%A8"><span class="toc-number">1.2.</span> <span class="toc-text">驱动</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Python%E7%8E%AF%E5%A2%83"><span class="toc-number">2.</span> <span class="toc-text">Python环境</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8%E5%AE%89%E8%A3%85%E7%8E%AF%E5%A2%83"><span class="toc-number">2.1.</span> <span class="toc-text">使用安装环境</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E5%AF%BB%E7%8E%AF%E5%A2%83"><span class="toc-number">2.2.</span> <span class="toc-text">创建寻环境</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BF%90%E8%A1%8C%E8%84%9A%E6%9C%AC"><span class="toc-number">2.3.</span> <span class="toc-text">运行脚本</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%99%84%E5%BD%95"><span class="toc-number">3.</span> <span class="toc-text">附录</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E6%96%87%E7%AB%A0"><span class="toc-number">4.</span> <span class="toc-text">参考文章</span></a></li></ol></div></div></div><div class="card-widget card-recent-post"><div class="card-content"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2020/12/31/%E4%BD%BF%E7%94%A8Python%E8%84%9A%E6%9C%AC%E5%AF%B9GiteePages%E8%BF%9B%E8%A1%8C%E4%B8%80%E9%94%AE%E9%83%A8%E7%BD%B2/" title="使用Python脚本对GiteePages进行一键部署"><img src="https://api.uomg.com/api/rand.avatar" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="使用Python脚本对GiteePages进行一键部署"/></a><div class="content"><a class="title" href="/2020/12/31/%E4%BD%BF%E7%94%A8Python%E8%84%9A%E6%9C%AC%E5%AF%B9GiteePages%E8%BF%9B%E8%A1%8C%E4%B8%80%E9%94%AE%E9%83%A8%E7%BD%B2/" title="使用Python脚本对GiteePages进行一键部署">使用Python脚本对GiteePages进行一键部署</a><time datetime="2020-12-31T02:23:36.000Z" title="发表于 2020-12-31 10:23:36">2020-12-31</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2020/12/30/%E6%90%AD%E5%BB%BA%E5%9F%BA%E4%BA%8EGiteePages%E7%9A%84%E5%9B%BE%E5%BA%8A/" title="搭建基于GiteePages的图床"><img src="https://api.uomg.com/api/rand.avatar" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="搭建基于GiteePages的图床"/></a><div class="content"><a class="title" href="/2020/12/30/%E6%90%AD%E5%BB%BA%E5%9F%BA%E4%BA%8EGiteePages%E7%9A%84%E5%9B%BE%E5%BA%8A/" title="搭建基于GiteePages的图床">搭建基于GiteePages的图床</a><time datetime="2020-12-30T07:52:07.000Z" title="发表于 2020-12-30 15:52:07">2020-12-30</time></div></div></div></div></div><div class="card-widget ads-wrap">true</div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 By Langkye</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">博客迁移正在迁移,更多请移步 <a href="https://www.cnblogs.com/langkyeSir" target="_blank"><b>我的博客园</b></a>~</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.spacingElementById('content-inner')
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.spacingElementById('content-inner')
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>function addGitalkSource () {
  const ele = document.createElement('link')
  ele.rel = 'stylesheet'
  ele.href= 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css'
  document.getElementsByTagName('head')[0].appendChild(ele)
}

function loadGitalk () {
  function initGitalk () {
    var gitalk = new Gitalk({
      clientID: 'a02879124f7b1193ecf2',
      clientSecret: 'e7d2d470e6ff28dc631f9c1c052e88869576f8d0',
      repo: 'blog_comment',
      owner: 'langkye',
      admin: ['langkye'],
      id: '0c0338ad638423c1bc094a5b8f21b9d1',
      language: 'zh-CN',
      perPage: 10,
      distractionFreeMode: false,
      pagerDirection: 'last',
      createIssueManually: false,
      updateCountCallback: commentCount
    })
    gitalk.render('gitalk-container')
  }

  if (typeof Gitalk === 'function') initGitalk()
  else {
    addGitalkSource()
    getScript('https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js').then(initGitalk)
  }
}

function commentCount(n){
  let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
  if (isCommentCount) {
    isCommentCount.innerHTML= n
  }
}

if ('Gitalk' === 'Gitalk' || !false) {
  if (false) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
  else loadGitalk()
} else {
  function loadOtherComment () {
    loadGitalk()
  }
}</script><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><div class="app-refresh" id="app-refresh"> <div class="app-refresh-wrap"> <label>✨ 网站已更新最新版本 👉</label> <a href="javascript:void(0)" onclick="location.reload()">点击刷新</a> </div></div><script>function showNotification(){if(GLOBAL_CONFIG.Snackbar){var t="light"===document.documentElement.getAttribute("data-theme")?GLOBAL_CONFIG.Snackbar.bgLight:GLOBAL_CONFIG.Snackbar.bgDark,e=GLOBAL_CONFIG.Snackbar.position;Snackbar.show({text:"已更新最新版本",backgroundColor:t,duration:5e5,pos:e,actionText:"点击刷新",actionTextColor:"#fff",onActionClick:function(t){location.reload()}})}else{var o=`top: 0; background: ${"light"===document.documentElement.getAttribute("data-theme")?"#49b1f5":"#1f1f1f"};`;document.getElementById("app-refresh").style.cssText=o}}"serviceWorker"in navigator&&(navigator.serviceWorker.controller&&navigator.serviceWorker.addEventListener("controllerchange",function(){showNotification()}),window.addEventListener("load",function(){navigator.serviceWorker.register("/sw.js")}));</script><div class="aplayer no-destroy" data-id="000PeZCQ1i4XVs" data-server="tencent" data-type="artist" data-fixed="true" data-mini="true" data-listFolded="false" data-order="random" data-preload="none" data-autoplay="false" muted></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="false" data-click="true"></script><script src="//code.tidio.co/bxabrxksa1honnx51afwynfpawh3dq78.js" async="async"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config_change',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"]):not([href="/enjoy/music/"]):not([href="/no-pjax/"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  if (typeof gtag === 'function') {
    gtag('config', '', {'page_path': window.location.pathname});
  }

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})


document.addEventListener('pjax:send', function () {
  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})</script><script>(function(){
  const bp = document.createElement('script');
  const curProtocol = window.location.protocol.split(':')[0];
  if (curProtocol === 'https') {
    bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
  }
  else{
    bp.src = 'http://push.zhanzhang.baidu.com/push.js';
  }
  bp.dataset.pjax = ''
  const s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(bp, s);
})()</script></div></body></html>